//: Playground - noun: a place where people can play

import UIKit

let array0 = Array<String>()
let array1 = ["cy"]

// 增
var arrayM0 = ["cy"]
arrayM0.append("ay")

// 删
var arrayM1 = ["cy", "ay", "onewaycat"]
arrayM1.remove(at: 0)
arrayM1

// 改
var arrayM2 = ["cy", "ay", "onewaycat"]
arrayM2[1] = "Alex"
arrayM2

// 查
let str = arrayM2[1]

// 遍历
// (1)
var arrayM3 = ["cy", "ay", "onewaycat"]
let count = arrayM3.count

for i in 0..<count {
    print(arrayM3[i])
}

// (2)
for item in arrayM3 {
    print(item)
}

// (3)
for (index, item) in arrayM3.enumerated() {
    print(item)
    print(index)
}

// 数组的合并
// 如果存放的是相同元素, 那么可以相加合并
let array5 = ["cy", "Alex"]
let array6 = ["ay", "one"]
let array7 = [7, 8]

let result = array5 + array6

